<template>
    <section class="index">
      <div class="topTitle blue getTop">
        <span class="goBack" @click="goBack"><i></i></span>
       节目中心
      </div>

       <div class="mpList">
          <ul>
            <li v-for="item in showData" @click="play(item)"><img :src="item.cover" alt=""></li>
          </ul>
       </div>

    </section>
    
</template>

<script>
import {Get,Post,Delete} from '@/config/api.js'

export default {
  name: 'Home',
  data () {
    return {
      showData:'',
      isPlaying:false,
      palyId:'',//播放的id
      url:'/static/music/1.mp3',
      img:'/static/images/appBanner01.jpg',
      audio:{
        currentTime:'',
        maxTime:''
      }
    }
  },
  mounted(){
      //$('#audio').css('display','none')
      //$('#music').play()

      this.getData()
  },
  methods:{

    play(val){
      this.$store.dispatch("mpStatic",val)
    },
    stop(){
        var audio =document.querySelector('#audio');
        audio.pause();
        //audio.currentTime = 0;
    },
    next(){
      $('#audio').css('display','block')
      this.url="/static/music/2.mp3"
    },
    onTimeupdate(res){
      this.audio.currentTime = res.target.currentTime
    },
    onLoadedmetadata(res){
      this.audio.maxTime = parseInt(res.target.duration)
    },
    //返回上一页
    goBack(){
      this.$router.go(-1)
    },
    async getData(id){
        await Get('/radio',this.$store.state.token).then((res)=>{
          this.$store.dispatch("mpData",res.data)
          this.showData=res.data
        })
    }

  }
}
</script>


